import com.demo.component.UserController;
import com.demo.controller.StudentController;
import com.demo.model.Student;
import com.demo.service.StudentService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/2/8
 */
public class App {
    public static void main(String[] args) {
        // 1.得到 Spring 的上下⽂对象，创建的时候需要配置 Spring 配置信息
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");//直接初始化对象
//        User user = (User) context.getBean("user");
//        User user1 = context.getBean(User.class);
//        User user2 = context.getBean("user",User.class);
//        System.out.println(user.sayHi());
//        UserController controller = context.getBean("userController", UserController.class);
//        controller.sayHi("userController");
//        Student stu = context.getBean("student",Student.class);//这里的名字就等于方法名
//        System.out.println(stu);
        StudentController sc = context.getBean("studentController", StudentController.class);
        sc.sayHi();
    }
}
